import FormModule from './FormModule.vue'
import { ref } from 'vue'

export default FormModule

export const useForm = () => {
  const ctx = ref<typeof FormModule>()
  const register = (vm: typeof FormModule) => {
    ctx.value = vm.ctx
  }
  return {
    init: (...args) => {
      ctx.value?.init(...args)
    },
    submitForm: () => {
      return ctx.value?.submitForm()
    },
    resetFields: () => {
      return ctx.value?.resetFields()
    },
    register,
  }
}
